www.gusucode.com > VC++ 简易二维平面CAD绘图程序-源码程序 > VC++ 简易二维平面CAD绘图程序-源码程序/code/CAD/DataBase.cpp
//Download by http://www.NewXing.com // DataBase.cpp: implementation of the CDataBase class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "DataBase.h" #include "Line.h" #include "Rectangle.h" #include "Circle.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CDataBase::CDataBase() { } CDataBase::~CDataBase() { } CShape * CDataBase::OpenObject(ifstream &ifs) { char className[255]; CShape *pShape = NULL; //读取类名 ifs>>className; //识别类名 if (strcmp(className,"CLine") == 0) { pShape = new CLine; } if(strcmp(className,"CCircle") == 0) { pShape = new CCircle; } if(strcmp(className,"CRectangle") == 0) { pShape = new CRectangle; } //文件无内容 if (pShape == NULL) return pShape; pShape->Open(ifs); return pShape; } void CDataBase::SaveObject(ofstream &ofs,CShape* pShape) { pShape->SaveClassName(ofs); pShape->Save(ofs); }